#!/bin/bash
#find uid from name
#set -x
binddn='cn=Manager,dc=jhc,dc=cn'
pwdfile=~/.ldappwd
basedn='dc=jhc,dc=cn'
name=$1

uid=$(ldapsearch -x -y "$pwdfile" -D "$binddn" -b "$basedn" -s sub "(cn=$name)" | grep '^uid: ' | sed 's/^uid: //')
echo "$uid"

